package com.nervenets.web.hibernate.dao;

import com.nervenets.web.enumeration.TypeType;
import com.nervenets.web.hibernate.domain.Type;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface TypeDao extends JpaRepository<Type, Long>, JpaSpecificationExecutor<Type> {
    Page<Type> findAllByType(TypeType type, Pageable pageable);

    Page<Type> findAllByTypeAndParentId(TypeType type, long parentId, Pageable pageable);

    Page<Type> findAllByTypeAndParentIdAndManagerId(TypeType type, long parentId, long managerId, Pageable pageable);

    List<Type> findAllBySystemIsTrueAndParentIdOrderByQueueDesc(long parentId);
}
